Optimal. Leaf size=119 \[ -\frac {4 a^3 (A-2 i B) x}{c}+\frac {4 a^3 (i A+2 B) \log (\cos (e+f x))}{c f}+\frac {a^3 (A-4 i B) \tan (e+f x)}{c f}+\frac {a^3 B \tan ^2(e+f x)}{2 c f}+\frac {4 a^3 (A-i B)}{c f (i+\tan (e+f x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.12, antiderivative size = 119, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78}
\begin {gather*} \frac {a^3 (A-4 i B) \tan (e+f x)}{c f}+\frac {4 a^3 (A-i B)}{c f (\tan (e+f x)+i)}+\frac {4 a^3 (2 B+i A) \log (\cos (e+f x))}{c f}-\frac {4 a^3 x (A-2 i B)}{c}+\frac {a^3 B \tan ^2(e+f x)}{2 c f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 78
Rule 3669
Rubi steps
\begin {align*} \int \frac {(a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{c-i c \tan (e+f x)} \, dx &=\frac {(a c) \text {Subst}\left (\int \frac {(a+i a x)^2 (A+B x)}{(c-i c x)^2} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \text {Subst}\left (\int \left (\frac {a^2 (A-4 i B)}{c^2}+\frac {a^2 B x}{c^2}-\frac {4 a^2 (A-i B)}{c^2 (i+x)^2}-\frac {4 i a^2 (A-2 i B)}{c^2 (i+x)}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=-\frac {4 a^3 (A-2 i B) x}{c}+\frac {4 a^3 (i A+2 B) \log (\cos (e+f x))}{c f}+\frac {a^3 (A-4 i B) \tan (e+f x)}{c f}+\frac {a^3 B \tan ^2(e+f x)}{2 c f}+\frac {4 a^3 (A-i B)}{c f (i+\tan (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(944\) vs. \(2(119)=238\).
time = 7.24, size = 944, normalized size = 7.93 \begin {gather*} \frac {(A-i B) \cos (2 f x) \cos ^4(e+f x) \left (-\frac {2 i \cos (e)}{c}-\frac {2 \sin (e)}{c}\right ) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {\cos ^2(e+f x) \left (\frac {B \cos (3 e)}{2 c}-\frac {i B \sin (3 e)}{2 c}\right ) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {(A-2 i B) \cos ^4(e+f x) \left (-\frac {4 f x \cos (3 e)}{c}+\frac {4 i f x \sin (3 e)}{c}\right ) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {(i A+2 B) \cos ^4(e+f x) \left (\frac {2 \cos (3 e) \log \left (\cos ^2(e+f x)\right )}{c}-\frac {2 i \log \left (\cos ^2(e+f x)\right ) \sin (3 e)}{c}\right ) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {\cos ^3(e+f x) \left (\frac {\cos (3 e)}{c}-\frac {i \sin (3 e)}{c}\right ) (A \sin (f x)-4 i B \sin (f x)) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f \left (\cos \left (\frac {e}{2}\right )-\sin \left (\frac {e}{2}\right )\right ) \left (\cos \left (\frac {e}{2}\right )+\sin \left (\frac {e}{2}\right )\right ) (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {(A-i B) \cos ^4(e+f x) \left (\frac {2 \cos (e)}{c}-\frac {2 i \sin (e)}{c}\right ) \sin (2 f x) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))}+\frac {x \cos ^4(e+f x) \left (\frac {2 A \cos (e)}{c}-\frac {4 i B \cos (e)}{c}-\frac {2 A \cos ^3(e)}{c}+\frac {4 i B \cos ^3(e)}{c}-\frac {4 i A \sin (e)}{c}-\frac {8 B \sin (e)}{c}+\frac {8 i A \cos ^2(e) \sin (e)}{c}+\frac {16 B \cos ^2(e) \sin (e)}{c}+\frac {12 A \cos (e) \sin ^2(e)}{c}-\frac {24 i B \cos (e) \sin ^2(e)}{c}-\frac {8 i A \sin ^3(e)}{c}-\frac {16 B \sin ^3(e)}{c}-\frac {2 A \sin (e) \tan (e)}{c}+\frac {4 i B \sin (e) \tan (e)}{c}-\frac {2 A \sin ^3(e) \tan (e)}{c}+\frac {4 i B \sin ^3(e) \tan (e)}{c}-i (A-2 i B) \left (\frac {4 \cos (3 e)}{c}-\frac {4 i \sin (3 e)}{c}\right ) \tan (e)\right ) (a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{(\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.21, size = 81, normalized size = 0.68
method | result | size |
derivativedivides | \(\frac {a^{3} \left (A \tan \left (f x +e \right )-4 i B \tan \left (f x +e \right )+\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-4 i A -8 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )-\frac {4 i B -4 A}{i+\tan \left (f x +e \right )}\right )}{f c}\) | \(81\) |
default | \(\frac {a^{3} \left (A \tan \left (f x +e \right )-4 i B \tan \left (f x +e \right )+\frac {B \left (\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-4 i A -8 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )-\frac {4 i B -4 A}{i+\tan \left (f x +e \right )}\right )}{f c}\) | \(81\) |
risch | \(-\frac {2 \,{\mathrm e}^{2 i \left (f x +e \right )} B \,a^{3}}{c f}-\frac {2 i {\mathrm e}^{2 i \left (f x +e \right )} A \,a^{3}}{c f}-\frac {16 i a^{3} B e}{f c}+\frac {8 a^{3} A e}{f c}+\frac {2 a^{3} \left (i A \,{\mathrm e}^{2 i \left (f x +e \right )}+5 B \,{\mathrm e}^{2 i \left (f x +e \right )}+i A +4 B \right )}{c f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}+\frac {8 a^{3} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B}{f c}+\frac {4 i a^{3} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A}{f c}\) | \(178\) |
norman | \(\frac {\frac {\left (-4 i B \,a^{3}+A \,a^{3}\right ) \left (\tan ^{3}\left (f x +e \right )\right )}{c f}+\frac {\left (-8 i B \,a^{3}+5 A \,a^{3}\right ) \tan \left (f x +e \right )}{c f}-\frac {4 \left (-2 i B \,a^{3}+A \,a^{3}\right ) x}{c}-\frac {8 i A \,a^{3}+9 B \,a^{3}}{2 c f}-\frac {4 \left (-2 i B \,a^{3}+A \,a^{3}\right ) x \left (\tan ^{2}\left (f x +e \right )\right )}{c}+\frac {B \,a^{3} \left (\tan ^{4}\left (f x +e \right )\right )}{2 c f}}{1+\tan ^{2}\left (f x +e \right )}-\frac {2 \left (i A \,a^{3}+2 B \,a^{3}\right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{c f}\) | \(192\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 5.61, size = 172, normalized size = 1.45 \begin {gather*} -\frac {2 \, {\left ({\left (i \, A + B\right )} a^{3} e^{\left (6 i \, f x + 6 i \, e\right )} + 2 \, {\left (i \, A + B\right )} a^{3} e^{\left (4 i \, f x + 4 i \, e\right )} - 4 \, B a^{3} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (-i \, A - 4 \, B\right )} a^{3} + 2 \, {\left ({\left (-i \, A - 2 \, B\right )} a^{3} e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, {\left (-i \, A - 2 \, B\right )} a^{3} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (-i \, A - 2 \, B\right )} a^{3}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )\right )}}{c f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, c f e^{\left (2 i \, f x + 2 i \, e\right )} + c f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A]
time = 0.50, size = 206, normalized size = 1.73 \begin {gather*} \frac {4 i a^{3} \left (A - 2 i B\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{c f} + \frac {2 i A a^{3} + 8 B a^{3} + \left (2 i A a^{3} e^{2 i e} + 10 B a^{3} e^{2 i e}\right ) e^{2 i f x}}{c f e^{4 i e} e^{4 i f x} + 2 c f e^{2 i e} e^{2 i f x} + c f} + \begin {cases} \frac {\left (- 2 i A a^{3} e^{2 i e} - 2 B a^{3} e^{2 i e}\right ) e^{2 i f x}}{c f} & \text {for}\: c f \neq 0 \\\frac {x \left (4 A a^{3} e^{2 i e} - 4 i B a^{3} e^{2 i e}\right )}{c} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 322 vs. \(2 (111) = 222\).
time = 0.73, size = 322, normalized size = 2.71 \begin {gather*} -\frac {2 \, {\left (\frac {2 \, {\left (-i \, A a^{3} - 2 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{c} + \frac {4 \, {\left (i \, A a^{3} + 2 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}{c} + \frac {2 \, {\left (-i \, A a^{3} - 2 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1\right )}{c} + \frac {5 \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{5} - 8 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{5} + 2 i \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 7 \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} - 10 \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 14 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - 2 i \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 7 \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 5 \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 8 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}{{\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + i \, \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i\right )}^{2} c}\right )}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 9.00, size = 139, normalized size = 1.17 \begin {gather*} \frac {B\,a^3\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,c\,f}+\frac {\frac {4\,A\,a^3-B\,a^3\,8{}\mathrm {i}}{c}+\frac {B\,a^3\,4{}\mathrm {i}}{c}}{f\,\left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )}-\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (\frac {B\,a^3\,2{}\mathrm {i}}{c}+\frac {a^3\,\left (2\,B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{c}\right )}{f}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (\frac {8\,B\,a^3}{c}+\frac {A\,a^3\,4{}\mathrm {i}}{c}\right )}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________